<template>
    <z-paging
        ref="paging"
        v-model="dataList"
        @query="queryList"
        empty-view-img="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/987eadb1d50949a0a7e25dbbd99abe30.png"
        empty-view-text="暂无内容"
        bg-color="#F6F6F6"
        auto-scroll-to-top-when-reload
    >
        <view class="">
            <view class="follow" v-for="(item, index) in dataList" :key="index">
                <view
                    class="flex_wrap row_middle row_between"
                    @click="toAdvisor(item.salesManId)"
                >
                    <view class="flex_wrap row_middle">
                        <u-image
                            width="108rpx"
                            height="108rpx"
                            shape="circle"
                            :src="item.avatar || MissingAvatar"
                            mode="aspectFill"
                        />
                        <view>
                            <u-text
                                size="36rpx"
                                color="#3D3D3D"
                                :text="item.salesmanName"
                                margin="0 0 0 22rpx"
                            ></u-text>
                            <u-text
                                size="28rpx"
                                color="#777777"
                                :text="item.salesManMobile"
                                margin="12rpx 0 0 22rpx"
                            ></u-text>
                        </view>
                    </view>
                    <view class="btn">查看</view>
                </view>
            </view>
        </view>
    </z-paging>
</template>

<script>
import { toHealthForServiceLog } from "@/api/statistics";
import { consultant } from "@/api/sign_in.js";
import { getCustomerIdBySalesmanId } from "@/api/card";

export default {
    data() {
        return {
            MissingAvatar:
                "https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/23/0e6265fd99fa49a9bacf3791420d6de6.png",
            dataList: [],
        };
    },
    methods: {
        async toAdvisor(salesManId) {
            const { data, code } = await getCustomerIdBySalesmanId(salesManId);
            console.log(salesManId, "e");
            setTimeout(() => {
                uni.navigateTo({
                    url:
                        "/pages_card/user_card/index?salesmanId=" +
                        salesManId +
                        "&customerId=" +
                        data,
                });
            }, 500);
        },
        async queryList(pageNo, pageSize) {
            const params = {
                pageNum: pageNo,
                pageSize: pageSize,
            };
            consultant(params)
                .then((res) => {
                    this.$refs.paging.complete(res.data.rows);
                })
                .catch(() => {
                    this.$refs.paging.complete(false);
                });
        },
    },
};
</script>

<style>
page {
    background: #f6f9ff;
}
</style>

<style lang="scss" scoped>
.follow {
    // width: 100%;
    padding: 24rpx 32rpx;
    background-color: #fff;
    margin-top: 16rpx;
    box-sizing: border-box;
}
.btn {
    width: 144rpx;
    height: 64rpx;
    background: #588bf3;
    border-radius: 10rpx;
    font-size: 28rpx;
    color: #ffffff;
    line-height: 64rpx;
    text-align: center;
}
</style>
